﻿<%@ Page Language="C#" MasterPageFile="~/Main.master" CodeBehind="EditList.aspx.cs" Inherits="DD_Extensions.EditList" %>
<%@ MasterType VirtualPath="~/Site.master" %>


<asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
	<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
		<DataControls>
			<asp:DataControlReference ControlID="FormView1" />
		</DataControls>
	</asp:DynamicDataManager>

	<h2 class="DDSubHeader">Edit <%= table.DisplayName %></h2>

	<asp:UpdatePanel ID="UpdatePanel1" runat="server">
		<ContentTemplate>
			<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
				HeaderText="List of validation errors" CssClass="DDValidator" />
			<asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="FormView1" Display="None" CssClass="DDValidator" />

			<asp:FormView 
				runat="server" 
				ID="FormView1" 
				DataSourceID="DetailsDataSource" 
				DefaultMode="Edit" 
				OnItemCommand="FormView1_ItemCommand" 
				OnItemUpdated="FormView1_ItemUpdated" 
				RenderOuterTable="false">
				<EditItemTemplate>
					<table id="detailsTable" class="DDDetailsTable" cellpadding="0">
						<asp:DynamicEntity runat="server" Mode="Edit" />
						<tr class="td">
							<td colspan="2" class="CommandCell">
								<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" CssClass="DDControl" Text="Save" />
								<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" CommandName="Cancel" CssClass="DDControl" Text="Cancel" ToolTip="Cancel Edit"/>
							</td>
						</tr>
					</table>
				</EditItemTemplate>
				<EmptyDataTemplate>
					<div class="DDNoItem">No such item.</div>
				</EmptyDataTemplate>
			</asp:FormView>

			<asp:FormView 
				runat="server"
				ID="ChildrenFormView" 
				RenderOuterTable="false"
				DataSourceID="DetailsDataSource">
			</asp:FormView>

			<asp:EntityDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true" 
                onupdated="DetailsDataSource_Updated" />

			<asp:QueryExtender TargetControlID="DetailsDataSource" ID="DetailsQueryExtender" runat="server">
				<asp:DynamicRouteExpression />
			</asp:QueryExtender>

		</ContentTemplate>
	</asp:UpdatePanel>
</asp:Content>

